using System;
using FluentNHibernate.AutoMap;
using Webshop20.Domain.Common;
using Webshop20.Domain.Shared.Products.Core;
using Webshop20.Infrastructure.Persistence.NH.AutoMappings.Conventions.Common;

namespace Webshop20.Infrastructure.Persistence.NH.AutoMappings
{
    public class ForProducts
    {
        public static AutoPersistenceModel GetPersistenceModel()
        {
            return
    AutoPersistenceModel.MapEntitiesFromAssemblyOf<Product>()
        .Where(x => x.Namespace == "Webshop20.Domain.Shared.Products.Core" && x.Name != "Discount")
        .ConventionDiscovery.AddFromAssemblyOf<IdConvention>()
        .WithSetup(
                                convention =>
                                {
                                    convention.IsBaseType = bt => bt == typeof(Entity);
                                    convention.IsComponentType = ct => ct == typeof (Discount);
                                }
                                    );
        }
    }
}